﻿import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
Rectangle{
    id: root
    //    title: "维护校正"
    width: parent.width
    height:  parent.height
    color: "white"
    radius: 12
    //    minimumWidth: 1430*dp
    //    minimumHeight: 860*dp
    //    maximumWidth: 1430*dp
    //    maximumHeight: 860*dp
    property int flagzsq: 1
    property int flagfm: 1
    property int flagzp: 0
    property int flagqb: 0
    property int flagjc: 0
    property int gdzsq: 1
    property int gdfm: 1
    property int gdzp: 0
    property int gdqb: 0
    property int gdjc: 0
    onVisibleChanged: {
        modelist.tableData=CMaintenance.getSyringInfo()
        zphcname.model=CExeConfig.zpgethclxdef()
    }

    Connections{  // qmlre
        target: CSignal
        onRefCommunicationLog:{
            logtab.setData(CMaintenance.getLog())
        }
    }
    Connections{
        target: CSignal
        onSendSyringRunMsg:{
            if(status==="0"){
                if(serial==="7"){
                    maintenanceToast.show("转盘执行完成",0)
                }
                else if(serial!="8")
                {
                    maintenanceToast.show(serial+"号注射器执行完成",0)
                }
            }
            else if(status==="1"){
                if(serial==="7"){
                    maintenanceToast.show("转盘正在运动中,请耐心等待",1)
                }
                else if(serial!="8")
                {
                    maintenanceToast.show(serial+"号注射器正在运动中,请耐心等待",1)
                }
            }
        }
        onSendResetMsg:{
            if(status==="0"){
                if(serial==="7"){
                    maintenanceToast.show("转盘复位完成",0)
                }
                else{
                    maintenanceToast.show(serial+"号注射器复位完成",0)
                }
            }
            else if(status==="1"){
                if(serial==="7"){
                    maintenanceToast.show("转盘正在运动中,请耐心等待",1)
                }
                else if(serial==="0")
                {
                    maintenanceToast.show("有电机正在运动中,请耐心等待",1)
                }
                else{
                    maintenanceToast.show(serial+"号注射器正在运动中,请耐心等待",1)
                }
            }
        }
        onSendAirPumpPressure:{
            kfmz.setText(openVal)
            gfmz.setText(closeVal)
        }
        onSendTurnTablePos:{
            zpwzbs.setText(turnTableVal)
        }
    }
    BoxWarning{
        id: qbsc
        box_text: "是否全部删除删除?"
        onAccept: {
            CMaintenance.delSyring("0")
            modelist.tableData=CMaintenance.getSyringInfo()
        }
    }

    BoxWarning{
        id: qdhfcs
        box_text: "确认恢复初始状态吗?"
        onAccept: {
            CMaintenance.restoreInitialState()
        }
    }
    BoxWarning{
        id: qdfw
        box_text: "确认复位吗?"
        onAccept: {
            CMaintenance.reset("0","0","")
        }
    }
    BoxWarning{
        id: qdxf
        box_text: "确认数据下发吗?"
        onAccept: {
            CMaintenance.saveData()
        }
    }
    // 主布局
    Rectangle{
        x:30*dp
        y:20*dp
        width: parent.width-2*x
        height: parent.height-2*x

        // 上边 ==========================================
        Item{
            id: layout_top
            height: 180*dp; width: parent.width
            Rectangle{
                Text {
                    id: tit
                    text: qsTr("维护校正")
                    font.bold: true
                    font.pixelSize: config.fontsize + 5*dp
                }
            }
            CustomButton{
                width: 100*dp
                height: 100*dp
                y: 50*dp
                title: "恢复初始"
                icon_color: "#56BD6C"
                button_color: isHovered? "#d9d9d9":"#F2F2F2"
                iconDirect: 1
                button_icon:"qrc:/picture/bt_hfcs.png"
                icon_size:33*dp
                onReleased: {
                    qdhfcs.show()
                }
            }
            CustomButton{
                width: 100*dp
                height: 100*dp
                x: 130*dp
                y: 50*dp
                title: "复位"
                icon_color: "#FFA200"
                button_color: isHovered? "#d9d9d9":"#F2F2F2"
                iconDirect: 1
                button_icon:"qrc:/picture/bt_fw.png"
                icon_size:33*dp
                onReleased: {
                    qdfw.show()
                }
                CustomTooltip{
                    visible: parent.isHovered
                    text: "复位到电机原点"
                }
            }
            CustomButton{
                width: 100*dp
                height: 100*dp
                x: 260*dp
                y: 50*dp
                title: "下发"
                icon_color: "#1677FF"
                button_color: isHovered? "#d9d9d9":"#F2F2F2"
                iconDirect: 1
                button_icon:"qrc:/picture/phwh_xf.png"
                icon_size:33*dp
                onReleased: {
                    qdxf.show()
                }
            }
            Rectangle{
                width: parent.width*0.38
                height: parent.height
                x: parent.width*0.62
                border.color: "#B8B7B5"
                color: "#E0E6E9"
                Image {
                    id: pic1
                    source: "qrc:/picture/wh_pic.png"
                    fillMode: Image.PreserveAspectFit
                    width: parent.width
                    height: parent.height
                }
                Rectangle{
                    x:20*dp
                    y:10*dp
                    Text {
                        text: qsTr("示意图")
                        font.bold: true
                        font.pixelSize: config.fontsize + 3*dp
                    }
                }
            }
        }
        // 下边
        Rectangle{
            id: layout_buttom
            y: layout_top.height + 10*dp
            width: parent.width
            height: parent.height - y
            radius: 10*dp
            border.color: "#B8B7B5"

            // 左半场
            ScrollView{
                y:10*dp
                id: scrollView
                width: parent.width*0.66
                height: parent.height-20*dp
                clip: true

                Column{
                    id: columnLayout
                    x:2*dp
                    y:40*dp
                    width: parent.width - 20*dp
                    height: parent.height-40*dp
                    spacing: 10*dp
                    Rectangle{
                        x:20*dp
                        //                        y:20*dp
                        height: 1*dp
                        width: scrollView.width-10*dp
                        color: "#B8B7B5"
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:40*dp
                        width: scrollView.width-10*dp
                        height: 30*dp
                        Rectangle{
                            x:0*dp
                            y:3*dp
                            Image {
                                source: "qrc:/picture/zsq.png"
                                width: 24*dp
                                height: 24*dp
                            }
                        }
                        Rectangle{
                            x:30*dp
                            y:3*dp
                            Text {
                                text: qsTr("注射器起始位置校正")
                                font.pixelSize: config.pointsize + 2*dp
                            }
                        }
                        PushButton{
                            x: scrollView.width-100*dp
                            y: 1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_width: 36*dp
                            icon_height: 28*dp
                            text_size: 0*dp
                            button_icon:{
                                if(isHover){
                                    return "qrc:/picture/ygd.png"
                                }else{
                                    if(gdzsq===0){
                                        return "qrc:/picture/wgd.png"
                                    }else{
                                        "qrc:/picture/ygd.png"
                                    }
                                    //                                    gdzsq===0?"qrc:/picture/wgd.png":"qrc:/picture/ygd.png"
                                }
                            }
                            onReleased: {
                                if(gdzsq===0){
                                    gdzsq=1
                                }else{
                                    gdzsq=0
                                }
                            }
                            CustomTooltip{
                                visible: parent.isHover
                                text: "固定"
                            }
                        }
                        PushButton{
                            x:scrollView.width-60*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:flagzsq===1?"qrc:/picture/xs.png":"qrc:/picture/xx.png"
                            onReleased: {
                                if(flagzsq===1){
                                    if(gdzsq===1){
                                        return
                                    }
                                    zsqta.visible=false
                                    modelist.visible=false
                                    flagzsq=0
                                    console.log(scrollView.width)
                                }else{
                                    zsqta.visible=true
                                    modelist.visible=true
                                    flagzsq=1
                                    if(gdfm===0){
                                        fmta.visible=false
                                        flagfm=0
                                    }
                                    if(gdzp===0){
                                        flagzp=0
                                    }
                                    if(gdqb===0){
                                        flagqb=0
                                    }
                                    if(gdjc===0){
                                        flagjc=0
                                    }
                                    console.log(scrollView.width)
                                }
                            }
                        }
                    }
                    Rectangle{
                        id:zsqta
                        x:20*dp
                        //                        y:80*dp
                        width: scrollView.width-40*dp
                        height: 60*dp
                        Row{
                            spacing: 10*dp
                            anchors.right: parent.right
                            PushButton{
                                defaultMode1: true
                                title: "新建"
                                width: 120*dp
                                height: 40*dp
                                onReleased: {
                                    newtype.mltype="0"
//                                    newtype.tablemodeldata=
//                                    newtype.hcna=""
                                    newtype.indextype=CMaintenance.getSerial()
                                    newtype.zsqsum=6
//                                    newtype.tablemodeldata=[]
                                    newtype.hcmod=CMaintenance.canInsertConsumablesType()
                                    newtype.zsqsum=CMaintenance.getSyringNum(CMaintenance.canInsertConsumablesType()[0])
                                    // 定义二维数组的行数和列数
                                    var rows = CMaintenance.getSyringNum(CMaintenance.canInsertConsumablesType()[0]);
                                    // 创建一个空的二维数组
                                    var twoDArray = [];
                                    // 使用嵌套循环初始化二维数组
                                    for (var i = 0; i < rows; i++) {
                                        // 为每一行创建一个新的数组
                                        twoDArray[i] = ["",CExeConfig.getzsqdef()[0],"","","","","mL/Min","1:1","0.6096",
                                                "3200","",""];
                                    }
                                    newtype.tablemodeldata=twoDArray
                                    newtype.show()
                                }
                            }
                            PushButton{
                                defaultMode1: true
                                title: "全部删除"
                                width: 120*dp
                                height: 40*dp
                                onReleased: {
                                    qbsc.show()
                                }
                            }
                            PushButton{
                                defaultMode1: true
                                title: "导入"
                                width: 120*dp
                                height: 40*dp
                                CustomTooltip{
                                    visible: parent.isHover
                                    text: "如果导入的耗材已存在，原有的耗材信息将会被覆盖"
                                }
                                onReleased: {
                                    var data=CMaintenance.importSyringConfig()
                                    if(data===0){
                                        maintenanceToast.show("导入成功",0)
                                    }
                                    else if(data===-1){
                                        maintenanceToast.show("文件不存在",1)
                                    }
                                    else if(data===-2){
                                        maintenanceToast.show("导入文件数据格式不正确",1)
                                    }
                                    modelist.tableData=CMaintenance.getSyringInfo()
                                }
                            }
                        }
                    }
                    CustomTableList{
                        id:modelist
                        x:20*dp
                        width: scrollView.width-40*dp
                        height: 160*dp
                        //                        showCheckedBox: true
                        title: ["序号", "耗材名称", "注射器数量", "最后修改时间"]
                        showHGridLine: true     // 显示横向网格线
                        showOperateButton: true
//                        showOperateButton2: true
                        tableData: CMaintenance.getSyringInfo()
                        operateButtonWidth:100*dp
                        onOperate: {
                            if(text==="1"){
                                newtype.mltype="1"
                                newtype.indextype=num
                                newtype.tablemodeldata=CMaintenance.getSyringDetails(hcname)
                                newtype.hcmod=[hcname]
                                newtype.zsqsum=CMaintenance.getSyringNum(hcname)
                                newtype.show()
                            }else if(text==="2"){
                                CMaintenance.delSyring(num)
                                modelist.tableData=CMaintenance.getSyringInfo()
                            }else if(text==="3"){
                                CMaintenance.setDefault(num)
                                modelist.tableData=CMaintenance.getSyringInfo()
                            }else if(text==="4"){
                                CMaintenance.exportSyringConfig(hcname)
                            }
                        }
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:20*dp
                        height: 1*dp
                        width: scrollView.width-10*dp
                        color: "#B8B7B5"
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:150*dp
                        width:  scrollView.width-10*dp
                        height: 30*dp

                        Rectangle{
                            x:0*dp
                            y:3*dp
                            Image {
                                source: "qrc:/picture/fm.png"
                                width: 24*dp
                                height: 24*dp
                            }
                        }
                        Rectangle{
                            x:30*dp
                            y:3*dp
                            Text {
                                text: qsTr("阀门")
                                font.pixelSize: config.pointsize + 2*dp
                            }
                        }
                        PushButton{
                            x:scrollView.width-100*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:{
                                if(isHover){
                                    return "qrc:/picture/ygd.png"
                                }else{
                                    if(gdfm===0){
                                        return "qrc:/picture/wgd.png"
                                    }else{
                                        "qrc:/picture/ygd.png"
                                    }
                                    //                                    gdfm===0?"qrc:/picture/wgd.png":"qrc:/picture/ygd.png"
                                }
                            }
                            onReleased: {
                                if(gdfm===0){
                                    gdfm=1
                                }else{
                                    gdfm=0
                                }
                            }
                            CustomTooltip{
                                visible: parent.isHover
                                text: "固定"
                            }
                        }
                        PushButton{
                            x:scrollView.width-60*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:flagfm===1?"qrc:/picture/xs.png":"qrc:/picture/xx.png"
                            onReleased: {
                                if(flagfm===1){
                                    if(gdfm===1){
                                        return
                                    }
                                    fmta.visible=false
                                    flagfm=0
                                }else{
                                    fmta.visible=true
                                    flagfm=1
                                    if(gdzsq===0){
                                        zsqta.visible=false
                                        modelist.visible=false
                                        flagzsq=0
                                    }
                                    if(gdzp===0){
                                        flagzp=0
                                    }
                                    if(gdqb===0){
                                        flagqb=0
                                    }
                                    if(gdjc===0){
                                        flagjc=0
                                    }
                                }
                            }
                        }
                    }
                    Rectangle{
                        id:fmta
                        x:20*dp
                        //                        y:200*dp
                        width: scrollView.width-40*dp
                        height: 150*dp
                        PushButton{
                            x:parent.width-510*dp
                            y:20*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "执行"
                            onReleased: {
                                CommunicationMethod.stepOperatingSimulation(2,[fmk.getText(),fmg.getText()])
                                console.log(fmk.getText())
                            }
                        }
                        PushButton{
                            x:parent.width-380*dp
                            y:20*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "重置"
                            onReleased: {
                                //                                fmk.setText("")
                                fmg.setText("")
                            }
                        }
                        PushButton{
                            x:parent.width-250*dp
                            y:20*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "全开"
                            onReleased: {
                                CommunicationMethod.stepOperatingSimulation(2,["开启","1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24"])
                            }
                        }
                        PushButton{
                            x:parent.width-120*dp
                            y:20*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "全关"
                            onReleased: {
                                CommunicationMethod.stepOperatingSimulation(2,["关闭","1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24"])
                            }
                        }
                        CustomComboBox{
                            id: fmk
                            x:parent.width/4-160*dp
                            y:80*dp
                            title: qsTr("操作")
                            width: 280*dp
                            height: 40*dp
                            editWidth: 200*dp
                            titleWidth: 80*dp
                            model: ["开启","关闭"]
                        }

                        Rectangle{
                            x:parent.width/4*3-160*dp
                            y:80*dp
                            width: 80*dp
                            height: 40*dp
                            Text {
                                x:0
                                text: qsTr("阀门选择")
                                font.pixelSize: config.fontsize
                                anchors.verticalCenter: parent.verticalCenter
                            }
                        }
                        CustomComboMultiBox{
                            id: fmg
                            x:parent.width/4*3-60*dp
                            y:80*dp
                            model: ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"]
                            editWidth: 200*dp
                        }

                    }
                    Rectangle{
                        x:20*dp
                        //                        y:480*dp
                        height: 1*dp
                        width: scrollView.width-10*dp
                        color: "#B8B7B5"
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:490*dp
                        width:  scrollView.width-10*dp
                        height: 30*dp
                        Rectangle{
                            x:0*dp
                            y:3*dp
                            Image {
                                source: "qrc:/picture/zp.png"
                                width: 24*dp
                                height: 24*dp
                            }
                        }
                        Rectangle{
                            x:30*dp
                            y:3*dp
                            Text {
                                text: qsTr("转盘")
                                font.pixelSize: config.pointsize + 2*dp
                            }
                        }
                        PushButton{
                            x:scrollView.width-100*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:{
                                if(isHover){
                                    return "qrc:/picture/ygd.png"
                                }else{
                                    if(gdzp===0){
                                        return "qrc:/picture/wgd.png"
                                    }else{
                                        "qrc:/picture/ygd.png"
                                    }
                                    //                                    gdzp===0?"qrc:/picture/wgd.png":"qrc:/picture/ygd.png"
                                }
                            }
                            onReleased: {
                                if(gdzp===0){
                                    gdzp=1
                                }else{
                                    gdzp=0
                                }
                            }
                            CustomTooltip{
                                visible: parent.isHover
                                text: "固定"
                            }
                        }
                        PushButton{
                            x:scrollView.width-60*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:flagzp===1?"qrc:/picture/xs.png":"qrc:/picture/xx.png"
                            onReleased: {
                                if(flagzp===1){
                                    if(gdzp===1){
                                        return
                                    }
                                    flagzp=0
                                }else{
                                    flagzp=1
                                    if(gdfm===0){
                                        fmta.visible=false
                                        flagfm=0
                                    }
                                    if(gdzsq===0){
                                        zsqta.visible=false
                                        modelist.visible=false
                                        flagzsq=0
                                    }
                                    if(gdqb===0){
                                        flagqb=0
                                    }
                                    if(gdjc===0){
                                        flagjc=0
                                    }
                                }
                            }
                        }
                    }
                    Rectangle{
                        x:20*dp
                        width: scrollView.width-40*dp
                        height: 120*dp
                        visible: flagzp===1
                        CustomComboBox{
                            id:zpbh
                            x:10*dp
                            y:70*dp
                            title: "位置"
                            width: 180*dp
                            titleWidth: 60*dp
                            editWidth: 120*dp
                            model: ["1","2","3","4","5","6","7","8","9","10","11"]
                        }

                        CustomInputText{
                            id:zpwzbs
                            x:210*dp
                            y:70*dp
                            title: "位置步数"
                            width: 180*dp
                            titleWidth: 60*dp
                            editWidth: 120*dp
                        }

                        CustomComboBox{
                            id:zphcname
                            x:410*dp
                            y:70*dp
                            title: "耗材名称"
                            width: 180*dp
                            titleWidth: 60*dp
                            editWidth: 120*dp
                            model: CExeConfig.zpgethclxdef()
                            onCurrentText: {            // 变更选择的耗材名称
                                if(getText()===""){
                                    cswzsz.enabled=false
                                }else{
                                    cswzsz.enabled=true
                                }
                            }
                        }


                        PushButton{
                            x:parent.width-640*dp
                            y:10*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "读取"
                            onReleased: {
                                CMaintenance.readPos(zpbh.getText())
                            }
                        }
                        PushButton{
                            x:parent.width-510*dp
                            y:10*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "执行"
                            onReleased: {
                                CMaintenance.turnTurnTable(zpbh.getText(),zpwzbs.getText())
                            }
                        }
                        PushButton{
                            x:parent.width-380*dp
                            y:10*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "保存"
                            onReleased: {
                                CMaintenance.saveData()
                            }
                        }
                        PushButton{
                            x:parent.width-250*dp
                            y:10*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "复位"
                            onReleased: {
                                CMaintenance.reset("0","7","")
                            }
                        }
                        CustomButton{
                            id:cswzsz
                            x:parent.width-120*dp
                            y:10*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "初始位置设置"
                            enabled: false
                            onReleased: {
                                if(zphcname.getText()!==""){
                                    CMaintenance.setInitialPosition(zpbh.getText(),zphcname.getText())
                                }
                            }
                            CustomTooltip{
                                visible: parent.isHovered
                                text: "设置初始位置时，必须填写耗材名称"
                            }
                        }
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:540*dp
                        height: 1*dp
                        width: scrollView.width-10*dp
                        color: "#B8B7B5"
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:150*dp
                        width:  scrollView.width-10*dp
                        height: 30*dp

                        Rectangle{
                            x:0*dp
                            y:3*dp
                            Image {
                                source: "qrc:/picture/wh_qb.png"
                                width: 24*dp
                                height: 24*dp
                            }
                        }
                        Rectangle{
                            x:30*dp
                            y:3*dp
                            Text {
                                text: qsTr("气泵")
                                font.pixelSize: config.pointsize + 2*dp
                            }
                        }
                        PushButton{
                            x:scrollView.width-100*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:{
                                if(isHover){
                                    return "qrc:/picture/ygd.png"
                                }else{
                                    if(gdqb===0){
                                        return "qrc:/picture/wgd.png"
                                    }else{
                                        "qrc:/picture/ygd.png"
                                    }
                                    //                                    gdqb===0?"qrc:/picture/wgd.png":"qrc:/picture/ygd.png"
                                }
                            }
                            onReleased: {
                                if(gdqb===0){
                                    gdqb=1
                                }else{
                                    gdqb=0
                                }
                            }
                            CustomTooltip{
                                visible: parent.isHover
                                text: "固定"
                            }
                        }
                        PushButton{
                            x:scrollView.width-60*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:flagqb===1?"qrc:/picture/xs.png":"qrc:/picture/xx.png"
                            onReleased: {
                                if(flagqb===1){
                                    if(gdqb===1){
                                        return
                                    }
                                    flagqb=0
                                }else{
                                    flagqb=1
                                    if(gdfm===0){
                                        fmta.visible=false
                                        flagfm=0
                                    }
                                    if(gdzp===0){
                                        flagzp=0
                                    }
                                    if(gdzsq===0){
                                        zsqta.visible=false
                                        modelist.visible=false
                                        flagzsq=0
                                    }
                                    if(gdjc===0){
                                        flagjc=0
                                    }
                                }
                            }
                        }

                    }
                    Rectangle{
                        id:qbre
                        x:0*dp
                        //                        y:50*dp
                        width: scrollView.width-40*dp
                        height: 120*dp
                        visible: flagqb===1
                        CustomInputText{
                            id:kfmz
                            x:parent.width/4-140*dp
                            y:60*dp
                            width: 280*dp
                            height: 40*dp
                            editWidth: 200*dp
                            titleWidth: 80*dp
                            title: "开阀门值"
                        }
                        CustomInputText{
                            id:gfmz
                            x:parent.width/4*3-140*dp
                            y:60*dp
                            width: 280*dp
                            height: 40*dp
                            editWidth: 200*dp
                            titleWidth: 80*dp
                            title: "关阀门值"
                        }
                        PushButton{
                            y:0*dp
                            x:parent.width-380*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "读取"
                            onReleased: {
                                CMaintenance.readAirPumpPressure()
                            }
                        }
                        PushButton{
                            y:0*dp
                            x:parent.width-250*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "设置"
                            onReleased: {
                                CMaintenance.setAirPumpPressure(kfmz.getText(),gfmz.getText())
                            }
                        }
                        PushButton{
                            y:0*dp
                            x:parent.width-120*dp
                            defaultMode1: true
                            width: 120*dp
                            title: "保存"
                            onReleased: {
                                CMaintenance.saveData()
                            }
                        }
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:540*dp
                        height: 1*dp
                        width: scrollView.width-10*dp
                        color: "#B8B7B5"
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:150*dp
                        width:  scrollView.width-10*dp
                        height: 30*dp

                        Rectangle{
                            x:0*dp
                            y:3*dp
                            Image {
                                source: "qrc:/picture/wh_jc.png"
                                width: 24*dp
                                height: 24*dp
                            }
                        }
                        Rectangle{
                            x:30*dp
                            y:3*dp
                            Text {
                                text: qsTr("检测")
                                font.pixelSize: config.pointsize + 2*dp
                            }
                        }
                        PushButton{
                            x:scrollView.width-100*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:{
                                if(isHover){
                                    return "qrc:/picture/ygd.png"
                                }else{
                                    if(gdjc===0){
                                        return "qrc:/picture/wgd.png"
                                    }else{
                                        "qrc:/picture/ygd.png"
                                    }
                                    //                                    gdjc===0?"qrc:/picture/wgd.png":"qrc:/picture/ygd.png"
                                }
                            }
                            onReleased: {
                                if(gdjc===0){
                                    gdjc=1
                                }else{
                                    gdjc=0
                                }
                            }
                            CustomTooltip{
                                visible: parent.isHover
                                text: "固定"
                            }
                        }
                        PushButton{
                            x:scrollView.width-60*dp
                            y:1*dp
                            width: 36*dp
                            height: 28*dp
                            icon_height: 28*dp
                            icon_width: 36*dp
                            button_icon:flagjc===1?"qrc:/picture/xs.png":"qrc:/picture/xx.png"
                            onReleased: {
                                if(flagjc===1){
                                    if(gdjc===1){
                                        return
                                    }
                                    flagjc=0
                                }else{
                                    flagjc=1
                                    if(gdfm===0){
                                        fmta.visible=false
                                        flagfm=0
                                    }
                                    if(gdzp===0){
                                        flagzp=0
                                    }
                                    if(gdqb===0){
                                        flagqb=0
                                    }
                                    if(gdzsq===0){
                                        zsqta.visible=false
                                        modelist.visible=false
                                        flagzsq=0
                                    }
                                }
                            }
                        }
                    }
                    Rectangle{
                        x:20*dp
                        //                        y:540*dp
                        height: 1*dp
                        width: scrollView.width-10*dp
                        color: "#B8B7B5"
                    }
                    Rectangle{
                        x:0*dp
                        //                        y:50*dp
                        width: scrollView.width
                        height: 40*dp
                    }
                }
            }

            Rectangle{ // 中间的竖线
                x: parent.width*0.67
                width: 1*dp
                height: parent.height
                color: "#B8B7B5"
            }
            // 右半场
            Item{
                x: parent.width * 0.68
                width: parent.width * 0.31
                height: parent.height
                Rectangle{
                    y:20*dp; x: 20*dp
                    Text {
                        text: qsTr("通信日志")
                        font.bold: true
                        font.pixelSize: config.fontsize + 3*dp
                    }
                }
                PushButton{
                    x:parent.width-140*dp
                    y:20*dp
                    button_icon: "qrc:/picture/br_qc.png"
                    title: "清除"
                    width: 60*dp
                    text_color: "#1677FF"
                    icon_height: 20*dp
                    icon_width: 20*dp
                    onReleased: {
                        logtab.setData([])
                        CMaintenance.delLog()
                    }
                }
                PushButton{
                    x:parent.width-70*dp
                    y:20*dp
                    button_icon: "qrc:/picture/bt_dc.png"
                    title: "导出"
                    width: 60*dp
                    text_color: "#1677FF"
                    icon_height: 20*dp
                    icon_width: 20*dp
                    onReleased: {
                        CMaintenance.exportLog()
                    }
                }
                Rectangle{
                    x: 20*dp
                    y:65*dp
                    color: "#B8B7B5"
                    width: parent.width-2*x
                    height: parent.height-70*dp
                    DataLog{
                        id:logtab
                    }
                }
            }
        }
    }

    Newzsq{
        id:newtype
        onUpdata: {
            modelist.tableData=CMaintenance.getSyringInfo()
        }
    }

    Toast{
        id: maintenanceToast
        x: (parent.width-width) * 0.5
        y: 100*dp
    }

}
